package com.seal.commons.exception;


/**
 * 业务异常，由code 和 message 组成， 方便在@ControllerAdvance 中拦截异常进行统一处理。非业务异常请显示的抛出受检异常
 */
public class BusinessException extends RuntimeException {

    protected static final int DEFAULT_ERROR_CODE = 9999;

    protected int code;

    protected String message;

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public BusinessException(ErrorCode errorCode, Throwable cause){
        super(errorCode.getMessage(), cause);
        this.code = errorCode.getCode();
    }

    public BusinessException(int errorCode, String message) {
        super(message);
        this.code = errorCode;
    }

    public BusinessException(int errorCode, String message, Throwable cause) {
        super(message, cause);
        this.code = errorCode;
    }


}
